package com.biavan.omservicos.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "papel_usuario", 
	uniqueConstraints = @UniqueConstraint(
		columnNames = { "papel", "login" }))
public class PapelUsuario implements Serializable {
	
	@Transient
	private static final long serialVersionUID = 5826894789349977049L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", 
		unique = true, nullable = false)
	private Long id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "login", nullable = false)
	private Usuario usuario;

	@Column(name = "papel", nullable = false, length = 45)
	private String papel;
 
	public PapelUsuario() {
	}
 
	public PapelUsuario(Usuario usuario, String papel) {
		this.usuario = usuario;
		this.papel = papel;
	}
 
	public Long getId() {
		return this.id;
	}
 
	public void setId(Long id) {
		this.id = id;
	}
 
	public Usuario getUsuario() {
		return this.usuario;
	}
 
	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}
 
	public String getPapel() {
		return this.papel;
	}
 
	public void setPapel(String papel) {
		this.papel = papel;
	}
}
